/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package biojavagoalz.io;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * File output class
 * @author Tadas
 */
public class PlainTextWriter implements OutputWriter {

   private BufferedWriter bw;
    private FileWriter fw;

    public PlainTextWriter(File file) {
        try {
            fw = new FileWriter(file);
            bw = new BufferedWriter(fw);
        } catch (FileNotFoundException e) {
            System.out.println("Output File not found...");
        } catch (IOException e) {
            Logger.getLogger(PlainTextReader.class.getName()).log(Level.SEVERE, null, e);
        }
    }

    public void close() {
        try {
            bw.flush();
            fw.close();
        } catch (IOException ex) {
            Logger.getLogger(PlainTextReader.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void print(String string) {
        try {
            bw.append(string);
            bw.newLine();
        } catch (IOException ex) {
            Logger.getLogger(PlainTextWriter.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
